<?php
/** php 发送流文件
* @param  String  $url  接收的路径
* @param  String  $file 要发送的文件
* @return boolean
*/
function sendStreamFile($url, $file){

    if(file_exists($file)){
        //$fileContents = file_get_contents($file)
        $fileHandle = fopen($file, "rb");
        $fileContents = stream_get_contents($fileHandle);
        fclose($fileHandle);
        $opts = array(
            'http' => array(
                'method' => 'POST',
                //'method' => 'GET',
                'header' => 'content-type:application/x-www-form-urlencoded',
                // 'header' => 'Content-Type: multipart/form-data\r\n',
                'content' => $fileContents
            )
        );

        $context = stream_context_create($opts);
        $response = file_get_contents($url, false, $context);
        $ret = json_decode($response, true);
        return $ret;

    }else{
        return false;
    }

}
//echo file_exists('public/iyuedan.mp3');exit;
$ret = sendStreamFile('http://localhost/streamfile/receiveStreamFile.php', '../public/images/Meinv153.jpg');
var_dump($ret);
?>